package com.beautify.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.beautify.entity.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserMapper extends BaseMapper<User> {


    @Select("select * from user where username=#{username} and password=#{password}")
    User login(String username,String password);

    void register(Integer types,String username,String password);

    @Select("select * from user where username=#{username}")
    User findByName(String username);

    void updateUser(User user);


    @Update("UPDATE user set password = #{newpassword} where userid = #{userid} and password = #{oldpassword}")
    int updatePassword(String oldpassword,String newpassword,Integer userid);

    @Delete("delete from user where userid = #{userid}")
    int deleteUser(Integer userid);

    @Select("SELECT password FROM user WHERE userid = #{userid}")
    String selectByPassword(String password);

    @Select("select * from user where userid = #{userid}")
    User getById(Integer userid);

    @Select("select * from user where preeJsid=#{sbs}")
    User findBypreeJsid(String sbs);

    void insertid(Integer types,Integer id);
}
